package io.github.wslxm.springbootplus2.client.sys.controller;

import io.github.wslxm.springbootplus2.client.sys.model.vo.USysConfigVO;
import io.github.wslxm.springbootplus2.core.base.controller.BaseController;
import io.github.wslxm.springbootplus2.core.constant.BaseConstant;
import io.github.wslxm.springbootplus2.core.result.Result;
import io.github.wslxm.springbootplus2.manage.sys.service.SysConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


/**
 * 系统全局数据信息配置表
 * <p>
 *  ::本代码由[兮家小二]提供的代码生成器生成,如有问题,请手动修改 ::作者CSDN:https://blog.csdn.net/qq_41463655 
 * </p>
 * @author wangsong
 * @email 1720696548@qq.com
 * @date 2020-08-31 18:31:44
 */
@RestController
@RequestMapping(BaseConstant.Uri.API_CLIENT + "/sys/config")
@Tag(name = "yh--base-plus--全局配置")
public class USysConfigController extends BaseController<SysConfigService> {


    @GetMapping(value = "/findByCode")
    @Operation(summary = "code 查询", description = "")
    @Parameter(name = "code", description = "配置 code", required = true, example = "")
    public Result<USysConfigVO> findByCode(@RequestParam String code) {
        return Result.successFind(baseService.findByCode(code));
    }


    @GetMapping(value = "/findByCodes")
    @Operation(summary = "codes 查询")
    @Parameter(name = "codes", description = "配置 codes, 多个逗号分隔", required = true, example = "")
    public Result<Map<String, USysConfigVO>> findByCodes(String codes) {
        return Result.success(baseService.findByCodes(codes));
    }


    @GetMapping(value = "/findByParentCode")
    @Operation(summary = "父级 code 查询", description = "查询指定父级 code 的所有下级配置")
    public Result<Map<String, USysConfigVO>> findByParentCode(@RequestParam String parentCode) {
        return Result.successFind(baseService.findByParentCode(parentCode));
    }

}
